package com.gao.security;

import com.gao.security.verificationcode.base.BaseCode;
import com.gao.security.verificationcode.base.BaseVerificationCodeHandler;
import com.gao.security.verificationcode.common.vo.VerficationCodeGenerationDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * <p></p>
 *
 * @author GaoShuangWen
 * @since 2019-07-29 16:52
 */
@SpringBootApplication
@EnableAutoConfiguration
public class App {

    private final BaseVerificationCodeHandler codeHandler;

    @Autowired
    public App(BaseVerificationCodeHandler codeHandler) {
        this.codeHandler = codeHandler;
    }

    public static void main(String[] args) {
        SpringApplication.run(App.class);
    }
    @RestController
    class AllController {
        @GetMapping("/login2")
        public String login() {
            return "登录失败！";
        }

        @GetMapping("/{type}/code")
        public BaseCode getImgCode(HttpServletRequest request,@PathVariable String type)  {
            return codeHandler.render(new VerficationCodeGenerationDto("img","123"));
        }
    }
}
